home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE22 / EX1.C next >
C/C++ Source or Header  |  1995-05-27  |  2KB  |  51 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    switch (uMsg)
  6.    {
  7.          case WM_COMMAND:
  8.                switch ( LOWORD( wParam )  )
  9.                {
  10.                      case IDM_TEST:
  11.                      {
  12.                            TCHAR szBuffer[64];
  13.                            TCHAR szTemp[16];
  14.                            TCHAR szFrench[] = { 0x41, 0xee, 0x6e, 0xe9, 0 };
  15.                            HDC   hDC = GetDC( hWnd );
  16.                            HFONT hOldFont;
  17.  
  18.                            // Copy into temporary buffer.
  19.                            lstrcpy( szTemp, szFrench );
  20.                            TextOut( hDC, 0, 0, szBuffer, wsprintf( szBuffer,
  21.                                     "Original String: %s", szTemp ) );
  22.                            TextOut( hDC, 0, 20, szBuffer, wsprintf( szBuffer,
  23.                                     "After CharUpper: %s", CharUpper( szTemp ) ) );
  24.                            TextOut( hDC, 0, 40, szBuffer, wsprintf( szBuffer,
  25.                                     "After CharLower: %s", CharLower( szTemp ) ) );
  26.  
  27.                            // Select an OEM font to do OEM display.
  28.                            hOldFont = SelectObject( hDC,
  29.                                                     GetStockObject( OEM_FIXED_FONT ) );
  30.                            CharToOem( szTemp, szTemp ); // in-place char->OEM conversion
  31.                            TextOut( hDC, 0, 60, szBuffer, wsprintf( szBuffer,
  32.                                     "After CharToOem: %s", szTemp));
  33.  
  34.                            // Return DC to original settings.
  35.                            DeleteObject( SelectObject( hDC, hOldFont ) );
  36.                            ReleaseDC( hWnd, hDC );
  37.                      }
  38.                      break;
  39.                      case IDM_EXIT:
  40.                            DestroyWindow( hWnd );
  41.                      break;
  42.                }
  43.                break;
  44.          case WM_DESTROY:
  45.                PostQuitMessage( 0 );
  46.                break;
  47.          default:
  48.                return (DefWindowProc(hWnd, uMsg, wParam, lParam));
  49.    }
  50.    return (NULL);
  51. }